//
//  launchScreenViewController.m
//  WonderfulNotes
//
//  Created by 千锋 on 16/1/20.
//  Copyright © 2016年 andy. All rights reserved.
//

#import "launchScreenViewController.h"
#import "LoginViewController.h"

#define img_number 4

@interface launchScreenViewController ()

@property(nonatomic,strong)UIScrollView * scrollView;

@end

@implementation launchScreenViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor purpleColor];
    [self createNewFeatureImgs];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)createNewFeatureImgs{
    
    self.scrollView = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    [self.view addSubview:self.scrollView];
    self.scrollView.pagingEnabled = YES;
    self.scrollView.bounces = NO;
    self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.scrollView.frame) * img_number , 0);
    CGFloat w = self.scrollView.frame.size.width;
    CGFloat h = self.scrollView.frame.size.height;
    
    for (int i=0; i<img_number; i++) {
        
        NSString * imageName = [NSString stringWithFormat:@"newfeature%02d",i+1];
        UIImageView * imgView = [[UIImageView alloc]initWithFrame:CGRectMake(w*i, 0, w, h)];
        imgView.image = [UIImage imageNamed:imageName];
        imgView.userInteractionEnabled = YES;
        
        [self.scrollView addSubview:imgView];
        
        if (i==img_number-1) {
            
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [imgView addSubview:btn];
            btn.backgroundColor = [UIColor grayColor];
            btn.layer.cornerRadius = 5;
            btn.frame = CGRectMake(0, 100, 80, 50);
            btn.center = (CGPoint){CGRectGetWidth(imgView.frame) * 0.3, CGRectGetHeight(imgView.frame) * 0.5 + 100};
            [btn addTarget:self action:@selector(showLogin) forControlEvents:UIControlEventTouchUpInside];
            
            UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
            [imgView addSubview:btn1];
            btn1.backgroundColor = [UIColor grayColor];
            btn1.frame =CGRectMake(0, 200, 80, 50);
            btn1.layer.cornerRadius = 5;
            btn1.center = (CGPoint){CGRectGetWidth(imgView.frame) * 0.6, CGRectGetHeight(imgView.frame) * 0.5 + 100};
            [btn1 addTarget:self action:@selector(showregister) forControlEvents:UIControlEventTouchUpInside];

        }
 
    }

}

-(void)showLogin{
    
    UIStoryboard * MainSb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    [self presentViewController:[MainSb instantiateViewControllerWithIdentifier:@"LoginViewController"] animated:YES completion:nil];
 
}

-(void)showregister{
    
    UIStoryboard * MainSb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    
    [self presentViewController:[MainSb instantiateViewControllerWithIdentifier:@"RegisterViewController"] animated:YES completion:nil];

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
